package com.web.action.backend;

import java.util.ArrayList;
import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.bo.Question;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import com.web.assist.Pic;
import com.web.util.PicLoad;

public class NormalQuestionAction extends ActionSupport implements ModelDriven<Question>,Preparable{
    private Question question = new Question();
    private List<Pic> pics = new ArrayList<Pic>();
    private String pic;


	public Question getQuestion() {
		return question;
	}

	public void setQuestion(Question question) {
		this.question = question;
	}

	public List<Pic> getPics() {
		return pics;
	}

	public void setPics(List<Pic> pics) {
		this.pics = pics;
	}

	public String getPic() {
		return pic;
	}

	public void setPic(String pic) {
		this.pic = pic;
	}
	@Override
	public Question getModel() {
		// TODO Auto-generated method stub
		return question;
	}
	@Override
	public void prepare() throws Exception {
		String picsPath = ServletActionContext.getServletContext().getRealPath(
				"/product-pic");
		pics = PicLoad.picsLoad(picsPath, "http://localhost:8080/teyoujia/product-pic/");
	}
	@Override
	public String execute() throws Exception {
		System.out.println(question.getQuestion()+" id:"+question.getQuestionId());
		return SUCCESS;
	}

	
}
